package edu.stanford.bmir.protege.web.client.ui.ontology.stkos.merger.statistical;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Label;

import edu.stanford.bmir.protege.web.client.project.Project;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.merger.MergenceResult;

public class StkosMergerStatisticalView extends Composite {

	interface StkosMergerStatisticalViewUiBinder extends
			UiBinder<HTMLPanel, StkosMergerStatisticalView> {
	}

	private static StkosMergerStatisticalViewUiBinder ourUiBinder = GWT
			.create(StkosMergerStatisticalViewUiBinder.class);

	private Project project;

	/** 类总数 */
	@UiField
	protected Label classCount;
	/** 原类数 */
	@UiField
	protected Label oldClassNumber;
	/** 合并的类数 */
	@UiField
	protected Label mergerClassNumber;

	/** 属性总数 */
	@UiField
	protected Label propertyCount;
	/** 原属性数 */
	@UiField
	protected Label oldPropertyNumber;
	/** 合并的属性数 */
	@UiField
	protected Label mergerPropertyNumber;

	/** 个体总数 */
	@UiField
	protected Label individualCount;
	/** 原个体数 */
	@UiField
	protected Label oldIndividualNumber;
	/** 合并的个体数 */
	@UiField
	protected Label mergerIndividualNumber;

	public StkosMergerStatisticalView(Project project) {
		this.project = project;

		HTMLPanel rootElement = ourUiBinder.createAndBindUi(this);
		initWidget(rootElement);
	}

	public void setMergerResult(MergenceResult result) {
		int totalClassNumber = 0, originalClassNumber = 0, mergedClassNumber = 0;
		int totalPropertyNumber = 0, originalPropertyNumber = 0, mergedPropertyNumber = 0;
		int totalIndividualNumber = 0, originalIndividualNumber = 0, mergedIndividualNumber = 0;
		if (result != null) {
			totalClassNumber = result.getTotalClassNumber();
			originalClassNumber = result.getOriginalClassNumber();
			mergedClassNumber = result.getMergedClassNumber();

			totalPropertyNumber = result.getTotalPropertyNumber();
			originalPropertyNumber = result.getOriginalPropertyNumber();
			mergedPropertyNumber = result.getMergedPropertyNumber();

			totalIndividualNumber = result.getTotalIndividualNumber();
			originalIndividualNumber = result.getOriginalIndividualNumber();
			mergedIndividualNumber = result.getMergedIndividualNumber();
		}
		this.classCount.setText(String.valueOf(totalClassNumber));
		this.oldClassNumber.setText(String.valueOf(originalClassNumber));
		this.mergerClassNumber.setText(String.valueOf(mergedClassNumber));

		this.propertyCount.setText(String.valueOf(totalPropertyNumber));
		this.oldPropertyNumber.setText(String.valueOf(originalPropertyNumber));
		this.mergerPropertyNumber.setText(String.valueOf(mergedPropertyNumber));

		this.individualCount.setText(String.valueOf(totalIndividualNumber));
		this.oldIndividualNumber.setText(String
				.valueOf(originalIndividualNumber));
		this.mergerIndividualNumber.setText(String
				.valueOf(mergedIndividualNumber));
	}
}
